<!DOCTYPE html>
<html>
<head>
  <title>Who can drive?</title>
</head>
<body>
  <script type="text/javascript">
  /* write a small program to loop over a list of names and ages,
     printing if each person is allowed to drive based on minAge,
     output should look like:

     tim (14) is not allowed to drive
     sara (33) is allowed to drive
     mike (17) is not allowed to drive
     julian (18) is allowed to drive
     eva (25) is allowed to drive
     amy (7) is not allowed to drive    
  */

  const minAge = 18;

  // names and ages are equal length lists (we will make objects (dicts) soon)
  const names = ['tim', 'sara', 'mike', 'julian', 'eva', 'amy'];
  const ages = [14, 33, 17, 18, 25, 7];

  for(let i=0; i < names.length; i++){
    let allowed = 'allowed'
    if(ages[i] < minAge){
      allowed = 'not ' + allowed;
    }

    console.log(names[i] + ' (' + ages[i] + ') is ' + allowed + ' to drive');
    // f-string like
    // console.log(`${names[i]} (${ages[i]}) is ${allowed} to drive`);
  }
  </script>
</body>
</html>
